package cn.cy.behavior.mediator.pattern;

/**
 * @author yangxq
 * @desc
 * @date 2025-05-10
 */
public class ChatMediator implements Mediator {

    private User colleague1;
    private User colleague2;

    public void registerColleagues(User colleague1, User colleague2) {
        this.colleague1 = colleague1;
        this.colleague2 = colleague2;
    }

    @Override
    public void notify(String message, Colleague colleague) {
        if (colleague == colleague1) {
            colleague2.receive(message);
        } else {
            colleague1.receive(message);
        }
    }

}
